Skip to content

Implemented Bogo Sort in Crystal #530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 25, 2018

Conversation

Vexatos
Copy link
Contributor

@Vexatos Vexatos commented Oct 20, 2018

Roughly based on the Lua implementation.

@june128 june128 added Implementation This provides an implementation for an algorithm. (Code and maybe md files are edited.) Hacktoberfest The label for all Hacktoberfest related things! labels Oct 20, 2018
@jiegillet
Copy link
Member

Everything looks great, but I think that Crystal has a shuffle function so maybe it's good to use it?

@Vexatos
Copy link
Contributor Author

Vexatos commented Oct 23, 2018

Good idea, probably.

@Vexatos Vexatos force-pushed the bogo-sort-crystal branch 2 times, most recently from 3b3e332 to d764df2 Compare October 23, 2018 18:23

def bogo_sort!(a)
while !is_sorted?(a)
a = a.shuffle
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function shuffle without ! creates a new array, remember that in crystal objects are passed by reference.

Suggested change
a = a.shuffle
a.shuffle!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that it matters, but sure.

@jiegillet jiegillet merged commit 6d7013d into algorithm-archivists:master Oct 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Hacktoberfest The label for all Hacktoberfest related things! Implementation This provides an implementation for an algorithm. (Code and maybe md files are edited.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants